home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Tools 1
/
Amiga Tools.iso
/
disk-tools
/
cd-tools
/
amicdrom
/
intui.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-06-06
|
7KB
|
245 lines
/* intui.c:
*
* System requester stuff.
*
* ----------------------------------------------------------------------
* This code is (C) Copyright 1993,1994 by Frank Munkert.
* All rights reserved.
* This software may be freely distributed and redistributed for
* non-commercial purposes, provided this notice is included.
* ----------------------------------------------------------------------
* History:
*
* 05-Jan-93 fmu Retry displaying CD-DA icon if WB is not open.
* 02-Jan-94 fmu Location for CD-DA icon may be defined by user.
* 11-Dec-93 fmu Fixed AddAppIconA() call for DICE.
* 28-Nov-93 fmu Added custom CD-DA icon; removed GetDefDiskObject() call.
* 09-Oct-93 fmu SAS/C support added
*/
#include <stdarg.h>
#include <stdio.h>
#include <exec/types.h>
#include <intuition/intuition.h>
#include <workbench/workbench.h>
#include <workbench/startup.h>
#include <clib/exec_protos.h>
#include <clib/intuition_protos.h>
#include <clib/icon_protos.h>
#include <clib/wb_protos.h>
#ifdef AZTEC_C
#include <pragmas/exec_lib.h>
#include <pragmas/intuition_lib.h>
#include <pragmas/icon_lib.h>
#include <pragmas/wb_lib.h>
#endif
#ifdef LATTICE
#include <pragmas/exec_pragmas.h>
#include <pragmas/intuition_pragmas.h>
#include <pragmas/icon_pragmas.h>
#include <pragmas/wb_pragmas.h>
#endif
#if defined(_DCC) && defined(REGISTERED)
#include <pragmas/exec_pragmas.h>
#include <pragmas/intuition_pragmas.h>
#include <pragmas/intuition_pragmas.h>
#include <pragmas/icon_pragmas.h>
#include <pragmas/wb_pragmas.h>
extern struct Library *SysBase;
#endif
#include "intui.h"
struct IntuitionBase *IntuitionBase;
struct Library *IconBase;
struct Library *WorkbenchBase;
struct MsgPort *g_app_port;
struct AppIcon *g_app_icon;
ULONG g_app_sigbit;
int g_retry_show_cdda_icon = FALSE;
USHORT g_image_data[] = {
/* Plane 0 */
0x0000,0x00FF,0xFE00,0x0000,0x0000,0x3F80,0x03F8,0x0000,
0x0003,0xC000,0x0007,0x8000,0x000C,0x0000,0x0000,0x6000,
0x0070,0x0000,0x0000,0x1C00,0x0080,0x0000,0x0000,0x0200,
0x0300,0x0000,0x0000,0x0080,0x0400,0x0000,0x0000,0x0040,
0x0800,0x0000,0x0000,0x0020,0x1000,0x0000,0x0000,0x0010,
0x2000,0x0000,0x0000,0x0008,0x4000,0x000F,0xE000,0x0004,
0x4000,0x003F,0xF800,0x0004,0x8000,0x0030,0x1800,0x0002,
0x8000,0x0040,0x0400,0x0002,0x8000,0x0040,0x0400,0x0002,
0x8000,0x0040,0x0400,0x0002,0x8000,0x0030,0x1800,0x0002,
0x4000,0x003F,0xF800,0x0004,0x4000,0x000F,0xE000,0x0004,
0x2000,0x0000,0x0000,0x0008,0x1000,0x0000,0x0000,0x0010,
0x0800,0x0000,0x0000,0x0020,0x0400,0x0000,0x0000,0x0040,
0x0200,0x0000,0x0000,0x0080,0x0080,0x0000,0x0000,0x0200,
0x0070,0x0000,0x0000,0x1C00,0x000C,0x0000,0x0000,0x6000,
0x0003,0xC000,0x0007,0x8000,0x0000,0x3F80,0x01F8,0x0000,
0x0000,0x00FF,0xFE00,0x0000,
/* Plane 1 */
0x0000,0x0000,0x0000,0x0000,0x0000,0x007F,0xFC00,0x0000,
0x0000,0x3FFF,0xFFF8,0x0000,0x0003,0xFF00,0x01FF,0x8000,
0x000F,0xE0FF,0xFE0F,0xE000,0x007F,0x1FFF,0xFFF1,0xFC00,
0x00FC,0xFF80,0x03FE,0x7F00,0x03F3,0xF07F,0xFC1F,0x9F80,
0x07EF,0x8FC0,0x07E3,0xEFC0,0x0F9E,0x7E3F,0xF8FC,0xF3E0,
0x1F79,0xF9FF,0xFF3F,0x3DF0,0x3EF7,0xE7F0,0x1FCF,0xDEF8,
0x3EEF,0xDFC0,0x07F7,0xEEF8,0x7DEF,0xDFC0,0x07F7,0xEF7C,
0x7DDF,0xBF80,0x03FB,0xF77C,0x7DDF,0xBF80,0x03FB,0xF77C,
0x7DDF,0xBF80,0x03FB,0xF77C,0x7DEF,0xDFC0,0x07F7,0xEF7C,
0x3EEF,0xDFC0,0x07F7,0xEEF8,0x3EF7,0xE7F0,0x1FCF,0xDEF8,
0x1F79,0xF9FF,0xFF3F,0x3DF0,0x0F9E,0x7E3F,0xF8FC,0xF3E0,
0x07EF,0x8FC0,0x07E3,0xEFC0,0x03F3,0xF07F,0xFC1F,0x9F80,
0x01FC,0xFF80,0x03FE,0x7F00,0x007F,0x1FFF,0xFFF1,0xFC00,
0x000F,0xE0FF,0xFE0F,0xE000,0x0003,0xFF00,0x01FF,0x8000,
0x0000,0x3FFF,0xFFF8,0x0000,0x0000,0x007F,0xFE00,0x0000,
0x0000,0x0000,0x0000,0x0000
};
struct Image g_disk_object_image = {
0, 0, /* top corner */
63, 31, 2, /* width, height, depth */
g_image_data,
0x03, 0x00, /* planepick, planeonoff */
NULL, /* next image */
};
UBYTE *g_tool_types[] = {
NULL
};
struct DiskObject g_disk_object = {
WB_DISKMAGIC,
WB_DISKVERSION,
{
NULL,
0, 0,
63, 32,
GADGIMAGE | GADGHCOMP,
RELVERIFY | GADGIMMEDIATE,
BOOLGADGET,
(APTR) &g_disk_object_image,
NULL,
},
0,
"",
(char **) g_tool_types,
NO_ICON_POSITION,
NO_ICON_POSITION,
NULL,
NULL,
0
};
long g_xpos = NO_ICON_POSITION;
long g_ypos = NO_ICON_POSITION;
void Init_Intui (void)
{
IntuitionBase = (struct IntuitionBase *)
OpenLibrary ((UBYTE *) "intuition.library", 37);
IconBase = OpenLibrary ((UBYTE *) "icon.library", 37);
if (!IconBase)
Display_Error ("cannot open icon.library");
WorkbenchBase = OpenLibrary ((UBYTE *) "workbench.library", 37);
if (!WorkbenchBase)
Display_Error ("cannot open workbench.library");
g_app_port = NULL;
g_app_sigbit = 0;
g_app_icon = NULL;
}
void Close_Intui (void)
{
if (WorkbenchBase)
CloseLibrary (WorkbenchBase);
if (IconBase)
CloseLibrary (IconBase);
if (IntuitionBase)
CloseLibrary ((struct Library *) IntuitionBase);
}
void Display_Error (char *p_message, ...)
{
va_list arg;
static struct EasyStruct req = {
sizeof (struct EasyStruct),
0,
(UBYTE *) "CDROM Handler Error",
NULL,
(UBYTE *) "Abort"
};
va_start (arg, p_message);
if (IntuitionBase) {
req.es_TextFormat = (UBYTE *) p_message;
EasyRequestArgs (NULL, &req, NULL, arg);
}
va_end (p_message);
}
void Show_CDDA_Icon (void)
{
if (!IconBase || !WorkbenchBase)
return;
g_disk_object.do_CurrentX = g_xpos;
g_disk_object.do_CurrentY = g_ypos;
if (g_app_icon)
Display_Error ("Show_CDDA_Icon called twice!");
g_app_port = CreateMsgPort ();
if (!g_app_port)
return;
g_app_sigbit = 1<<g_app_port->mp_SigBit;
#ifdef _DCC
{
struct DiskObject *tmp =
AddAppIconA (0, 0, (UBYTE *) "CD-DA", g_app_port,
NULL, &g_disk_object, NULL);
g_app_icon = tmp;
}
#else
g_app_icon = AddAppIconA (0, 0, (UBYTE *) "CD-DA", g_app_port,
NULL, &g_disk_object, NULL);
#endif
/* AddAppIconA may fail if the Workbench has not yet been loaded.
*/
if (!g_app_icon) {
DeleteMsgPort (g_app_port);
g_app_port = NULL;
g_retry_show_cdda_icon = TRUE;
return;
}
g_retry_show_cdda_icon = FALSE;
}
void Hide_CDDA_Icon (void)
{
struct Message *msg;
g_retry_show_cdda_icon = FALSE;
if (!IconBase || !WorkbenchBase)
return;
if (g_app_icon)
RemoveAppIcon (g_app_icon);
if (g_app_port) {
while (msg = GetMsg (g_app_port))
ReplyMsg (msg);
DeleteMsgPort (g_app_port);
}
g_app_port = NULL;
g_app_sigbit = 0;
g_app_icon = NULL;
}